package com.example.myapplication.HomeRecyclerViewFragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.myapplication.HomeRecyclerViewAdapter.JingPinKeChengAdapter;
import com.example.myapplication.HomeRecyclerViewFragment.HomeRecyclerViewBean.JingPinKeChengBean;
import com.example.myapplication.R;

import java.util.ArrayList;
import java.util.List;

public class JingPinKeCheng extends Fragment {
    List<JingPinKeChengBean> list=new ArrayList<>();
    JingPinKeChengAdapter jingPinKeChengAdapter;
    RecyclerView recyclerView;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_jipinkecheng,container,false);
        initView(view);
        return view;
    }

    private void initView(View view) {
        recyclerView=view.findViewById(R.id.JingPinKeCheng_RL);
        list.add(new JingPinKeChengBean(R.mipmap.hometanketiaozhanzhe,"付费","挑战者主战坦克"));
        list.add(new JingPinKeChengBean(R.mipmap.hometankebaoer,"付费","豹二A6主战坦克"));
        list.add(new JingPinKeChengBean(R.mipmap.hometanket90,"付费","T90主战坦克"));
        list.add(new JingPinKeChengBean(R.mipmap.hometanke99,"付费","99式主战坦克"));
        list.add(new JingPinKeChengBean(R.mipmap.hometankem1a2,"付费","M1A2主战坦克"));
        //添加布局管理器
        LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this.getActivity());
        //设置布局滑动是水平还是垂直 默认垂直
        linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        //设置布局管理器
        recyclerView.setLayoutManager(linearLayoutManager);
        jingPinKeChengAdapter=new JingPinKeChengAdapter(list);
        recyclerView.setAdapter(jingPinKeChengAdapter);

    }
}
